<!DOCTYPE html>
<html lang="en">
</hea>
<meta charset="UTF-8">
<title>slogin</title>
<script src="/static/js/jquery.min.js"></script>
</head>
<body>

<br><br>
<p>简单模式</p>
<button onclick="jdlogin()">简单模式</button>
<hr><br>
<p>密码模式</p>
<input type="text" id="username">
<input type="text" id="password">
<button onclick="mmlogin()">密码模式</button>
<hr><br>
<p>授权码模式</p>
<input type="text" id="susername">
<input type="text" id="spassword">
<button onclick="sqlogin()">授权码-code获取</button>

<script>
    $(function () {

    });

    function jdlogin() {
        $.ajax({
            url: '/oauth/token',
            type: 'post',
            data: {grant_type: 'client_credentials', scope: 'select'},
            headers: {
                // ccid ccsecret - client_credentials
                'Authorization': 'Basic Y2NpZDpjY3NlY3JldA=='
            },
            success: function (data) {
                console.log(data);
            }
        });
    }

    function mmlogin() {
        var uname = $("#username").val();
        var pword = $("#password").val();
        $.ajax({
            url: '/oauth/token',
            data: {username: uname, password: pword, grant_type: 'password', scope: 'select'},
            type: 'post',
            headers: {
                // client_ant_page client_ant_page_secret - password
                'Authorization': 'Basic Y2xpZW50X2FudF9wYWdlOmNsaWVudF9hbnRfcGFnZV9zZWNyZXQ='
            },
            success: function (data) {
                console.log(data);
            }
        })
    }

    function sqlogin() {
        var uname = $("#susername").val();
        var uword = $("#spassword").val();
        $.ajax({
            url: '/oauth/authorize',
            // data: {username: uname, password: uword, grant_type: 'authorization_code', scope: 'select'},
            data: {
                response_type: 'code',
                client_id: 'acid',
                // grant_type: 'authorization_code',
                state: 'xxcxxc',
                redirect_uri: 'http://127.0.0.1:4444/self/test'

            },
            type: 'post',
            headers: {
                // acid acsecret - authorization_code
                // 'Authorization': 'Basic YWNpZDphY3NlY3JldA=='
            },
            success: function (data) {
                console.log(data);
            }
        });
    }

</script>

</body>
</html>